package com.party.admin.task;

import com.party.core.model.log.LogType;
import com.party.core.service.log.ILogEventService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 日志清除系统日志
 * Created by wei.li
 *
 * @date 2017/9/26 0026
 * @time 15:03
 */

@Component(value = "quartzLogEvent")
public class QuartzLogEvent {

    @Autowired
    private ILogEventService logEventService;

    protected static Logger logger = LoggerFactory.getLogger(QuartzLogEvent.class);

    public void clear(){
        try {
            logEventService.deleteForDate(LogType.SYSTEM_LOG.getCode(), 5);
            logEventService.deleteForDate(LogType.BEHAVIOR_LOG.getCode(), 30);
        } catch (Exception e) {
            logger.error("清除日志异常", e);
        }
    }
}
